var assert = require('assert');
var should = require('should');
var util = require('util');
var zlib = require('zlib');
var _ = require('lodash');
var buildCheck = require('../../app/libs/buildCheck');
var config = require('../config');

suite('测试BuildCheck', function () {
    suite('验证路径', function () {
        test('验证路径不会碰在一起的', function () {
            var build_list = [];
            var road_list = [36, 37, 38, 39, 40, 41, 42];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(true);
        });

        test('验证路径是碰在一起的', function () {
            var build_list = [];
            var road_list = [107, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(false);
        });

        test('路的头不正确', function () {
            var build_list = [];
            var road_list = [108, 109, 110, 111, 112, 113, 114, 115, 116, 117];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(false);
        });

        test('路的尾不正确', function () {
            var build_list = [];
            var road_list = [107, 108, 109, 110, 111, 112, 113, 114, 115, 116];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(false);
        });

        test('路的头和尾都不正确', function () {
            var build_list = [];
            var road_list = [108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(false);
        });

        test('路连不起来', function () {
            var build_list = [];
            var road_list = [109, 110, 111, 112, 113, 114, 115, 116, 117];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(false);
        });

        test('建筑没靠在路旁边', function () {
            var build_list = [1];
            var road_list = [107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(false);
        });

        // test('建筑靠在路旁边', function () {
        //     var build_list = [82, 83];
        //     var road_list = [67, 68, 69, 70, 71, 72, 73, 74, 75];
        //     var ruin_list = [];
        //     buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(true);
        // });

        // test('建筑靠在路旁边,有路障', function () {
        //     var build_list = [82, 83];
        //     var road_list = [67, 68, 69, 70, 71, 72, 73, 74, 75];
        //     var block_list = [67];
        //     var ruin_list = [];
        //     buildCheck.isValid(build_list, block_list, road_list, ruin_list).should.eql(true);
        // });

        test('建筑靠在路旁边', function () {
            var build_list = [95, 88];
            var road_list = [107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117];
            var block_list = [107, 107];
            var ruin_list = [];
            buildCheck.isValid(build_list, block_list, road_list, ruin_list).should.eql(false);
        });

        test('建筑靠在路旁边', function () {
            var build_list = [95, 88];
            var road_list = [107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117];
            var block_list = [188];
            var ruin_list = [];
            buildCheck.isValid(build_list, block_list, road_list, ruin_list).should.eql(false);
        });

        test('建筑靠在路旁边', function () {
            var build_list = [95, 88];
            var road_list = [107, 109, 110, 111, 112, 113, 114, 115, 116, 117];
            var block_list = [188];
            var ruin_list = [];
            buildCheck.isValid(build_list, block_list, road_list, ruin_list).should.eql(false);
        });
    });

    suite('客户端出现错误', function () {
        test('验证路径不会碰在一起的', function () {
            var build_list = [91, 121, 127];
            var road_list = [107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117];
            var ruin_list = [];
            buildCheck.isValid(build_list, [], road_list, ruin_list).should.eql(false);
        });
    });
});
